﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using APNS.NET;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace APNSUnitTests.given_a_feedback
{
   
    public class when_I_create_feedback
    {

        [TestClass]
        public class from_a_byte_array
        {

            [TestMethod]
            public void then_valid_feed_back_should_be_returned()
            {
                byte[] feedbackBytes = new byte[] { 45, 56, 63, 88, 12, 12, 63, 88, 150, 198, 48, 47, 2, 248, 120, 186, 40, 194, 183, 21, 51, 8, 204, 226, 157, 5, 174, 49, 65, 154, 220, 125, 181, 164, 206, 110, 92, 22 };
                byte[] expectedTokenBytes = new byte[] { 63, 88, 150, 198, 48, 47, 2, 248, 120, 186, 40, 194, 183, 21, 51, 8, 204, 226, 157, 5, 174, 49, 65, 154, 220, 125, 181, 164, 206, 110, 92, 22 };

                var feedback = Feedback.FromBytes(feedbackBytes);
                var tokenBytes = feedback.DeviceToken.ToByteArray();

                Assert.AreEqual(new DateTime(2016, 11, 30, 20, 35, 57),feedback.Timestamp);
                for (int i = 0; i < expectedTokenBytes.Length; i++)
                    Assert.AreEqual(expectedTokenBytes[i], tokenBytes[i]);
            }

        }

        
    }
}
